<?php
	class Controller_Tipmanager extends Controller_Abstract
	{
		function actionIndex()
		{
			$tipModel = new TipManager();
			$tipArray = $tipModel->getTipByFields();
			$this->_view['tipArray'] = $tipArray;
		}
		
		function actionGettipinfo()
		{
			if($this->_context->isGET()){
				$tipId = $this->_context->get('tipid', '');
				$tipModel = new TipManager();
				$tip = $tipModel->getTipByFields( array('tip.id' => $tipId) );
				
				return json_encode($tip);
			}
		}
		
		function actionEdit()
		{
			if($this->_context->isPOST()){
				
				$tipId = $this->_context->post('tipinfo_id', '');
				$tipInfo = array();
				$tipInfo['font_size'] = $this->_context->post('tipinfo_fs', '');
				$tipInfo['font_color'] = $this->_context->post('tipinfo_fc', '');
				$tipInfo['bg_color'] = $this->_context->post('tipinfo_bc', '');
				$tipInfo['tip_width'] = $this->_context->post('tipinfo_tipWidth', '');
				$tipInfo['tip_height'] = $this->_context->post('tipinfo_tipHeight', '');
				$tipInfo['tip_lineheight'] = $this->_context->post('tipinfo_tipLineHeight', '');
				$tipInfo['tip_padding'] = $this->_context->post('tipinfo_tipPadding', '');
				$tipInfo['tip_text'] = $this->_context->post('tipinfo_tiptext', '');
				$tipInfo['description'] = $this->_context->post('tipinfo_description', '');
				
				$tipModel = new TipManager();
				$result = $tipModel->update($tipInfo, $tipId);
				return json_encode($result);
			}
		}
	}
?>